package org.codeart.command.example01;

import java.util.Map;

/**
 * 具体命令
 */
public class OrderCommand implements Command {

    // 接收者对象引用
    private final Chef receiver;

    private final Order order;

    public OrderCommand(Chef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.printf("%d 桌的订单: \n", order.getDiningTable());
        for (Map.Entry<String, Integer> entry : order.getFoodMenu().entrySet()) {
            receiver.makeFood(entry.getValue(), entry.getKey());
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.printf("%d 桌的菜品已经上齐\n", order.getDiningTable());
    }
}
